package com.jn.rxjava.views;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import androidx.appcompat.app.AppCompatActivity;
import com.jn.rxjava.R;

public class WeatherActivity extends AppCompatActivity {
    private EditText editTextCityName;
    private Button buttonGetWeather;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_weather);

        editTextCityName = findViewById(R.id.editTextCityName);
        buttonGetWeather = findViewById(R.id.buttonGetWeather);

        buttonGetWeather.setOnClickListener(v -> {
            String cityName = editTextCityName.getText().toString();
            if (!cityName.isEmpty()) {
                Intent intent = new Intent(WeatherActivity.this, WeatherDetailActivity.class);
                intent.putExtra("CITY_NAME", cityName);
                startActivity(intent);
            }
        });
    }
}
